#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

int main()
{
	unsigned int n = 0;
	unsigned int arr[100000] = { 0 };
	unsigned int price = 0;
	unsigned int money = 0;
	unsigned int max_money = 0;
	unsigned int optinal_price = 0;
	unsigned int i = 0;
	unsigned int j = 0;
	unsigned int temp = 0;
	int flag = 1;
	scanf("%u", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%u", &arr[i]);
	}
	
	for (i = 0; i < n - 1; i++)
	{
		flag = 1;
		for (j = 0; j < n - 1 - i; j++)
		{
			if (arr[j] > arr[j + 1])
			{
				temp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = temp;
				flag = 0;
			}
		}
		if (1 == flag)
			break;

	}

	for (i = 0; i < n; i++)
	{
		price = arr[i];
		money = arr[i] * (n - i);
		if (money > max_money)
		{
			max_money = money;
			optinal_price = price;
		}

	}
	
	printf("%u %u", max_money, optinal_price);

	return 0;
}